home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_09 / niemann / today.c < prev   
Encoding:
C/C++ Source or Header  |  1994-08-07  |  768 b   |  30 lines

  1. #include <stdio.h>
  2. #include <fcntl.h>
  3. #include <sys\stat.h>
  4. #include <io.h>
  5. #include <dos.h>
  6.  
  7. /* return 1 if file date is today, 0 otherwise */
  8. int main(int argc, char *argv[]) {
  9.     int fd;
  10.     struct ftime ftime;
  11.     struct date stime;
  12.  
  13.     fd = open (argv[1], O_RDONLY|O_BINARY);
  14.     if (fd == -1) return (0);
  15.     if (getftime (fd, &ftime)) return (0);
  16.     getdate (&stime);
  17.     if (stime.da_year == (ftime.ft_year + 1980)
  18.     &&  stime.da_mon == ftime.ft_month
  19.     &&  stime.da_day == ftime.ft_day)
  20.         return (1);
  21.     return (0);
  22.     }
  23.  
  24. As can be seen, today returns a 1 if the designated file is
  25. dated today, and a 0 otherwise.  A sample invocation, from autoexec.bat,
  26. follows:
  27.  
  28. today scandisk.log
  29. if not errorlevel 1 scandisk /autofix /nosave /nosummary i:
  30.